package com.nbsaas.boot.site.rest.convert;

import com.nbsaas.boot.site.data.entity.DynamicPageCatalog;
import com.nbsaas.boot.site.api.domain.response.DynamicPageCatalogResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 页面分类-实体对象转化成响应对象
*/

public class DynamicPageCatalogResponseConvert  implements Converter<DynamicPageCatalogResponse,DynamicPageCatalog> {

    @Override
    public DynamicPageCatalogResponse convert(DynamicPageCatalog source) {
        DynamicPageCatalogResponse  result = new  DynamicPageCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                        result.setParent(source.getParent().getId());
                    }

                    try {
                        if(source.getParent()!=null){
                            result.setParentName(source.getParent().getName());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

